/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.showcase.client.page;

import com.cleangwt.bootstrap.client.ui.Button;
import com.cleangwt.bootstrap.client.ui.CheckField;
import com.cleangwt.bootstrap.client.ui.DateBox;
import com.cleangwt.bootstrap.client.ui.GroupFormPanel;
import com.cleangwt.bootstrap.client.ui.InputGroup;
import com.cleangwt.bootstrap.client.ui.ListBox;
import com.cleangwt.bootstrap.client.ui.NumberBox;
import com.cleangwt.bootstrap.client.ui.RadioField;
import com.cleangwt.bootstrap.client.ui.TextArea;
import com.cleangwt.bootstrap.client.ui.TextBox;
import com.cleangwt.page.client.PageContext.CodeSplit;
import com.cleangwt.page.client.PageContext.Page;
import com.cleangwt.page.client.PageContext.Prefetch;
import com.cleangwt.showcase.client.component.ShowcasePage;
import com.cleangwt.showcase.client.resource.DataSource;
import com.cleangwt.showcase.client.resource.PageGroups;

/**
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
@Prefetch(PageGroups.BASE_WIDGET)
@CodeSplit
@Page
public class FormControlDemo extends ShowcasePage {

  public FormControlDemo() {
    super("Form Panel & Form Controls",
        "Integrate bootstrap's grid system and other form-control style. "
            + "Refer to <a href='http://getbootstrap.com/css/#forms'>Bootstrap</a>",
        "FormControlDemo.java");

    GroupFormPanel layout = new GroupFormPanel();
    TextBox txtf = new TextBox();
    DateBox datf = new DateBox();
    ListBox lstf = new ListBox("Select");
    NumberBox decf = new NumberBox();
    TextArea txta = new TextArea();
    RadioField radf = new RadioField(false);
    CheckField chkf = new CheckField(true);
    InputGroup inputGroup1 = new InputGroup();
    InputGroup inputGroup2 = new InputGroup();

    setContentWidget(layout);
    layout.build().add("TextBox", txtf).div(6).add("DateBox", datf).div(6);
    layout.build().add("ListBox", lstf).div(6).add("NumberBox", decf).div(6);
    layout.build().add("RadioField", radf).div(6).add("CheckField", chkf).div(6);
    layout.build().add("InputGrop1", inputGroup1).div(6).add("InputGrop2", inputGroup2).div(6);
    layout.build().add("TextArea", txta).div(6);

    inputGroup1.addButton(new Button("Button"));
    inputGroup1.addControl(new TextBox());
    inputGroup1.addAddon("Addon");

    inputGroup2.addDropdown("Dropdown").addLink("Link1", "#").addLink("Link2", "#");

    inputGroup2.addControl(new TextBox());
    inputGroup2.addAddon("<input type='checkbox'/>");

    lstf.setOptions(DataSource.getABCOptions());
    radf.setOptions(DataSource.getABCOptions());
    chkf.setOptions(DataSource.getABCOptions());
  }

}
